#include "Enemy.h"

Enemy::Enemy(){};
Enemy::~Enemy(){};

void Enemy::burst(){
	int t_rand = (rand()%100)%50;
	if(t_rand == 0){
		Bullet *t_Bullet = new Bullet;
		t_Bullet->Initialize(m_bulletFileName);
		t_Bullet->Set_Data(V2DF(m_PhysicObject.m_position.x, m_PhysicObject.m_position.y), 
			V2DF((float)(rand()%20-10), (float)(rand()%20-10)), 1.0f, 0.0f, 400.0f);
		t_Bullet->m_PhysicObject.m_physic_object_type = PHYSIC_OBJECT_TYPE_CIRCLE;
		t_Bullet->m_PhysicObject.m_radius = 4.0f;
		m_BulletList.Insert_ToEnd(t_Bullet);
		m_PhysicSystem->Create((&t_Bullet->m_PhysicObject));
		t_rand = (rand()%1);
		if(t_rand == 0){
			Bullet *t_Bullet = new Bullet;
			t_Bullet->Initialize(m_bulletFileName);
			t_Bullet->Set_Data(V2DF(m_PhysicObject.m_position.x, m_PhysicObject.m_position.y), 
				V2DF((float)(rand()%20-10), (float)(rand()%20-10)), 1.0f, 0.0f, 400.0f);
			t_Bullet->m_PhysicObject.m_physic_object_type = PHYSIC_OBJECT_TYPE_CIRCLE;
			t_Bullet->m_PhysicObject.m_radius = 4.0f;
			m_BulletList.Insert_ToEnd(t_Bullet);
			m_PhysicSystem->Create((&t_Bullet->m_PhysicObject));
		}
	}
};

void Enemy::update() {
	m_PhysicObject.m_velocity.normalize();
	m_PhysicObject.m_velocity.multiply(m_speed);

	burst();

	Entity::update();
}
void Enemy::render() {
	Entity::render();
}
void Enemy::release(){
	Entity::release();
};